const mongoose = require("mongoose")
const Schema = mongoose.Schema

const activitySchema = new Schema({
  // 活动名称
  name: {
    type: String,
    required: true,
  },
  // 活动创办者
  author: {
    ref: "admins",
    type: Schema.Types.ObjectId,
    required: true,
  },
  // 活动起始时间
  startTime: {
    type: Number,
    required: true,
  },
  // 活动结束时间
  endTime: {
    type: Number,
    required: true,
  },
  // 活动地点
  place: {
    type: String,
    required: true,
  },
  // 活动介绍
  des: {
    type: String,
    required: true,
  },
  // 参与人数
  participant: {
    type: Number,
    default: (Math.random() * 1000) | 0,
  },
  // 创建时间
  time: {
    type: Date,
    default: Date.now,
  },
})

module.exports = mongoose.model("activity", activitySchema)
